#bar_plot
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
x <- c('girrafes', 'oranges', 'monkeys')
y <- c(20,14,23)
plot_ly(type='bar' , x=x,y=y, color = x)
#iris
plot_ly(iris , x = ~Sepal.Width , y = ~Sepal.Length , type = 'bar', color = ~Species , width = 2)
#mean and sd by grouping data
dt <- group_by(iris , Species) %>%
summarise(means = mean(Sepal.Length))
dt
## # A tibble: 3 x 2
## Species means
## <fct> <dbl>
## 1 setosa 5.01
## 2 versicolor 5.94
## 3 virginica 6.59
plot_ly(data = dt , type = 'bar', x = dt$Species , y = dt$means , color = dt$Species)